// vim: foldmethod=marker : foldmarker=<<<,>>>
/*
 File: rod.c
 Generated-From: rod.nw
*/
#include "hooverPch.h"

#include "branch/branch.h"
#include "hoover/rod.h"
#include "nis/page.rh"
hoover_rod_p create__hoover_rod(HINSTANCE instance) {
 hoover_rod_p this=claim__heap_steward(&justCommon__heap_steward,sizeof(hoover_rod_t));
 SIGNAL(null(this),none,fail0);
 mzero(this,sizeof(hoover_rod_t));
 this->instance=instance;
 this->heap=&justCommon__heap_steward;

 register__nis_page(this);
 return this;
fail1: retract__heap_steward(&justCommon__heap_steward,this,sizeof(hoover_rod_p));
fail0: return NULL;
 };

v_t demolish__hoover_rod(hoover_rod_p this) {
 DestroyWindow(this->nis);
 retract__heap_steward(&justCommon__heap_steward,this,sizeof(hoover_rod_p));
 };
#define MENU_HEIGHT 26

// navigate 
i_t constructAndNavigate__hoover_rod(hoover_rod_p this, int showMode) {
 SIPINFO si;
 HWND h;

 mzero(&si,sizeof(SIPINFO)); 
 si.cbSize=sizeof(SIPINFO);
 SHSipInfo(SPI_GETSIPINFO,0,&si,0);
 
 h=CreateWindowEx( 
   0
  ,className__nis_page,L"Hoover NI"
  ,WS_VISIBLE
  ,CW_USEDEFAULT,CW_USEDEFAULT
  ,si.rcVisibleDesktop.right-si.rcVisibleDesktop.left
  ,si.rcVisibleDesktop.bottom-si.rcVisibleDesktop.top
   -((si.fdwFlags&SIPF_ON)?0:MENU_HEIGHT)
  ,0,0,this->instance,this
  );
 SIGNAL(null(h),none,fail0);

 ShowWindow(h,showMode); 
 SetForegroundWindow(h);
 UpdateWindow(h);
 this->nis=h;
 PostMessage(this->nis,WM_COMMAND,MAKEWPARAM(UPDATE__nis_page,0),0);
 return 1;
fail0: return 0;
 };


v_t singletonify__hoover_rod() {
 HANDLE h=FindWindow(className__nis_page,0);
 if (h!=NULL) { SetForegroundWindow(h); ExitThread(0); };
 };
